{extend name="admin@public/base" /}
{block name="main-content"}
	<div class="page-content">
	<script src="__PUBLIC__/ueditor/ueditor.config.js" type="text/javascript"></script>
	<script src="__PUBLIC__/ueditor/ueditor.all.js" type="text/javascript"></script>
	<link href="__PUBLIC__/ppy/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />
	<script src="__PUBLIC__/ppy/js/fileinput.js" type="text/javascript"></script>
	<script src="__PUBLIC__/ppy/js/fileinput_locale_zh.js" type="text/javascript"></script>
		<!--主题-->
		<div class="page-header">
			<h1>
				您当前操作
				<small>
					<i class="ace-icon fa fa-angle-double-right"></i>
					修改{$model.model_title}
				</small>
			</h1>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<form class="form-horizontal ajaxForm2" name="plug_ad_runedit" method="post" action="{:url('admin/Model/cmsrunedit')}">
					<input type="hidden" name="{$model['model_pk']}" value="{$model_pkid}" />
                    <input type="hidden" name="id" value="{$model_id}" />
					{foreach name="fields_data" item="f" key="k" }
                        {switch name="f['type']" }
                            {case value="baidu_map"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="text" name="{$k}" class="col-xs-6 col-sm-6" value="{$f.value|htmlspecialchars}"
                                    {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="text"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="text" name="{$k}" class="col-xs-6 col-sm-6" value="{$f.value|htmlspecialchars}"
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="number|large_number|currency"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="number" name="{$k}" class="col-xs-6 col-sm-6" value="{$f.value|htmlspecialchars}"
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="datetime"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="text" name="{$k}" class="datetime-picker col-xs-6 col-sm-6" value="{$f.value|date='Y-m-d H:i:s',###}"
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="date"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="text" name="{$k}" class="date-picker col-xs-6 col-sm-6" value="{$f.value|date='Y-m-d',###}"
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="switch"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="checkbox" value='1' name="{$k}" class="ace ace-switch ace-switch-4 btn-flat" {if condition="$f.value eq 1"}checked{/if}
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}/>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="bigtext"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <textarea name="{$k}" class="col-xs-6 col-sm-6"
                                           {if condition="in_array('readonly',$f['rules'])"} readonly="readonly" {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}>{$f.value|htmlspecialchars}
                                    </textarea>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="richtext"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <textarea name="{$k}" rows="100%" style="width:100%" id="myEditor_{$k}">{$f.value}</textarea>
                                    <script type="text/javascript">
                                        var editor_{$k} = new UE.ui.Editor();
                                        editor_{$k}.render("myEditor_{$k}");
                                    </script>
                                </div>
                            </div>
                            {/case}
                            {case value="selectnumber|selecttext"}
                            {if condition="$k eq $model['model_cid']"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <select name="{$k}" class="col-xs-6 col-sm-6" {if condition="in_array('required',$f['rules'])"} required {/if}>
                                    {foreach name="f.option" item="vo"}
                                    <option value="{$vo.id}" {if condition="$vo.id eq $model_cid"} selected {/if} class="bgc">{$vo.lefthtml}{$vo.menu_name}({if condition="$vo.menu_l eq 'zh-cn'"}中{else /}英{/if})</option>
                                    {/foreach}
                                    </select>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {else /}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <select name="{$k}" class="col-xs-6 col-sm-6"
                                    {if condition="in_array('readonly',$f['rules'])"} disabled {/if}
                                    {if condition="in_array('required',$f['rules'])"} required {/if}>
                                    {foreach name="f.option" item="vv" key="kk"}
                                    <option value="{$kk|htmlspecialchars}" {if condition="$kk eq $f['value']"} selected {/if}>{$vv}</option>
                                    {/foreach}
                                    </select>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red">{if condition="in_array('required',$f['rules'])"}*{/if}</span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/if}
                            {/case}
                            {case value="checkbox"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    {foreach name="f.option" item="vv" key="kk"}
                                    <label>
                                        <input {if condition="in_array($kk,$f['value'])"}checked{/if} class="ace ace-checkbox-2" name="{$k}[]" type="checkbox" value="{$kk|htmlspecialchars}" />
                                        <span class="lbl"> {$vv}</span>
                                    </label>
                                    {/foreach}
                                    <span class="lbl">&nbsp;&nbsp;<span class="red"></span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="imagefile"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <input type="hidden" name="checkpic_{$k}" id="checkpic_{$k}" value="{$f.value}" />
                                    <input type="hidden" name="oldcheckpic_{$k}" id="oldcheckpic_{$k}" value="{$f.value}" />
                                    <a href="javascript:;" class="file" title="点击选择所要上传的图片">
                                        <input type="file" data-field="{$k}" name="pic_one_{$k}[]" id="file_{$k}" multiple="multiple"/>
                                        选择上传文件
                                    </a>
                                    <span class="lbl">&nbsp;&nbsp;<img src="{$f.value|get_imgurl}" width="100" height="70" id="img_{$k}" ></span>
                                    <a href="javascript:;" onclick="return backpic2('{$f.value|get_imgurl}','{$k}');" title="还原修改前的图片" class="file">
                                        撤销修改
                                    </a>
                                    <span class="lbl">&nbsp;&nbsp;<span class="red"></span>{$f.description|htmlspecialchars}</span>
                                </div>
                            </div>
                            {/case}
                            {case value="images"}
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> {$f.title}：  </label>
                                <div class="col-sm-10">
                                    <label>
                                        <span class="btn btn-minier btn-success"  data-toggle="modal" data-target="#myModal">查看已上传的图片</span>
                                    </label>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group" id="pic_list">
                                <div class="col-sm-10 col-sm-offset-2" style="padding-top:5px;">
                                    <input id="file-5" name="pic_all[]" type="file" class="file"  multiple data-preview-file-type="any" data-upload-url="#" data-preview-file-icon=""><br />
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <input name="pic_oldlist" type="hidden" id="pic_oldlist" type="text" size="130" value="{$f.value}" >
                            <!-- 显示模态框（Modal） -->
                            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog" style="width:80%">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"
                                                    aria-hidden="true">×
                                            </button>
                                            <h4 class="modal-title" id="myModalLabel">
                                                操作已上传的多图
                                            </h4>
                                        </div>
                                        <div class="modal-body">
                                            <div class="row">
                                                <div class="col-xs-12">
                                                    <div class="form-group">
                                                        <div class="col-sm-10">
                                                            <ul>
                                                                {volist name="f.images" id="image"}
                                                                <div class="file-preview-frame" data-fileindex="0" id="id{$i}">
                                                                    <img src="{$image|get_imgurl}" class="file-preview-image" style="width:auto;height:160px;">
                                                                    <div class="file-thumbnail-footer">
                                                                        <div class="file-actions">
                                                                            <div class="file-footer-buttons">
                                                                                <a class="red" href="javascript:;" onclick="return delall({$i},'{$image}');" title="回收站">
                                                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                                                </a>
                                                                            </div>
                                                                            <div class="clearfix"></div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                {/volist}
                                                            </ul>
                                                        </div>
                                                    </div>
                                                    <div class="space-4"></div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button class="btn btn-primary">
                                                若想取消修改，请刷新当前页面
                                            </button>
                                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                                关闭
                                            </button>
                                        </div>
                                    </div><!-- /.modal-content -->
                                </div><!-- /.modal-dialog -->
                            </div><!-- /.modal -->
                            {/case}
                            {default /}
                            <p class="label-danger">
                                未知字段 <b>{$f['type']}</b>
                            </p>
                        {/switch}
					{/foreach}
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" type="submit">
								<i class="ace-icon fa fa-check bigger-110"></i>
								保存
							</button>
							&nbsp; &nbsp; &nbsp;
							<button class="btn" type="reset">
								<i class="ace-icon fa fa-undo bigger-110"></i>
								重置
							</button>
						</div>
					</div>
				</form>
			</div><!--col-xs-12-->
		</div><!--row-->
	</div><!-- /.page-content -->
{/block}
{block name="scripts"}
<script>
    $(".date-picker").datepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        todayHighlight: true,
        language:'zh-CN',
    });
    $(".datetime-picker").datetimepicker({
        format: 'yyyy-mm-dd hh:ii:ss',
        autoclose: true,
        todayHighlight: true,
        language:'zh-CN',
    });
</script>
{/block}